<h1><?php echo dl_lang_general("main.messages_detail"); ?></h1>
<?php
$id = (isset($_GET["arg1"]) ? $_GET["arg1"] : 0);

$s = dibi::query("SELECT m.id, a.name, m.date, m.mess_read, m.title, m.date, m.message, m.html
                    FROM account a, account_messages m
                   WHERE a.id = m.mess_from
                     AND m.mess_to = %i", $data["user"]["id"],
                    "AND m.id = %i", $id);
$r = $s->fetchAll();

if (count($r) == 0)
{
    echo html_error(dl_lang_general("msg.messages_stolen"));
}
else
{
    if ($r[0]->mess_read == 0)
    {
        dibi::query("UPDATE account_messages SET mess_read = '1' WHERE id = %i", $id);
    }
    
    $text = $r[0]->message;
    if ($r[0]->html == 0)
    {
            $text = htmlspecialchars($text);
    }
    $text = str_replace("\n", "<br />", $text);
    ?>
    <div class="message-title"><?php echo $r[0]->title; ?></div>
    <div class="message-from"><?php echo "Od: <b>" . $r[0]->name . "</b>, " . date("d.m.Y H:i", $r[0]->date); ?></div>
    <p>
        <?php echo $text; ?>
    </p>
    <button onclick="window.location.href='<?php echo $base."messages/new/".$id; ?>';"><?php echo dl_lang_general("main.messages_reply"); ?></button> <button onclick="if (confirm('<?php echo dl_lang_general("msg.messages_delete_this"); ?>')) window.location.href='<?php echo $base."xdeleteMessage/".$id; ?>'; return false;"><?php echo dl_lang_general("main.messages_delete_this"); ?></button>
    <?php
}
?>
